/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package biblio.dao;

import biblio.modelo.Categoria;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @categoria Grnmnd
 */
@Stateless
public class CategoriaDao extends AbstractDao<Categoria> implements CategoriaDaoLocal {
    @PersistenceContext(unitName = "Biblioteca-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public CategoriaDao() {
        super(Categoria.class);
    }

    
    //POR CLAVE
    @Override
    public boolean FindDuplicity(Categoria categoria) {
        Query q=em.createNamedQuery("Autor.findByClave");
        q.setParameter("clave", categoria.getClave());
        return !q.getResultList().isEmpty();
    }
    
}
